package org.niit.dao

import org.niit.util.JDBCUtil

class MengRealTimeDao {

  //五：不同用户价值判断  ----->   表

  // 一、实时监测每5秒新用户占比变化  ---->  表zhangTime1
  def insertTime1(windowTs: String , ageGroup: String, conversionRate: String): Unit = {
    val conn = JDBCUtil.getConnection

    JDBCUtil.executeUpdate(conn,
      """
        |INSERT INTO MengTime1 (windowTs,ageGroup, conversionRate) VALUES (?, ?, ?)
        |""".stripMargin,
      Array(windowTs, ageGroup, conversionRate)
    )

    conn.close()
  }

  //二、不同设备用户三步行为统计
  def insertTime2(time:String,rate:String): Unit = {
    val conn = JDBCUtil.getConnection

    JDBCUtil.executeUpdate(conn,
      """
        |INSERT INTO MengTime2 (time,rateMap) VALUES (?, ?) on duplicate key update rateMap = rateMap + ?
        |""".stripMargin,
      Array(time,rate,rate)
    )

    conn.close()
  }

  //三、不同用户在不同设备完成支付的实时支付率
  def insertTime3(time:String,rate:String): Unit = {
    val conn = JDBCUtil.getConnection

    JDBCUtil.executeUpdate(conn,
      """
        |INSERT INTO MengTime3 (time,ratioMap) VALUES (?, ?) on duplicate key update ratioMap = ratioMap + ?
        |""".stripMargin,
      Array(time,rate,rate)
    )

    conn.close()
  }


  //四、不同性别年龄用户访问列表页的实时次数
  def insertTime4(time:String,rate:String): Unit = {
    val conn = JDBCUtil.getConnection

    JDBCUtil.executeUpdate(conn,
      """
        |INSERT INTO MengTime4 (time,ratioMap) VALUES (?, ?) on duplicate key update ratioMap = ratioMap + ?
        |""".stripMargin,
      Array(time,rate,rate)
    )

    conn.close()
  }

  //五、用户在不同来源不同设备的产品页次数
  def insertTime5(time:String,rate:String): Unit = {
    val conn = JDBCUtil.getConnection

    JDBCUtil.executeUpdate(conn,
      """
        |INSERT INTO MengTime5 (time,avgPagesMap) VALUES (?, ?) on duplicate key update avgPagesMap = avgPagesMap + ?
        |""".stripMargin,
      Array(time,rate,rate)
    )

    conn.close()
  }

  //六、不同用户在不同市场的支付率
  def insertTime6(time:String,rate:String): Unit = {
    val conn = JDBCUtil.getConnection

    JDBCUtil.executeUpdate(conn,
      """
        |INSERT INTO MengTime6 (time,countMap) VALUES (?, ?) on duplicate key update countMap = countMap + ?
        |""".stripMargin,
      Array(time,rate,rate)
    )

    conn.close()
  }





}
